package pl.sind.blip;

import java.io.InputStream;
import java.util.Properties;

import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import pl.sind.blip.BlipConnector;
import pl.sind.blip.BlipConnectorException;
import pl.sind.http.HttpConnector;
import pl.sind.http.auth.AuthenticationStrategy;
import pl.sind.http.auth.BasicAuthenticationStrategy;
import pl.sind.http.basic.SimpleJavaHttpConnector;

@RunWith(JUnit4.class)
public abstract class BaseBlipTestCase {
	Properties props;
	String username;
	String password;
	String baseurl;

	@Before
	public void setUp() throws Exception {
		props = new Properties();
		InputStream is = this.getClass().getClassLoader()
				.getResourceAsStream("test.properties");
		props.load(is);
		username = props.getProperty("username");
		password = props.getProperty("password");
//		baseurl = props.getProperty("baseurl");
		Thread.sleep(5000);
	}

	protected BlipConnector newConnector() throws BlipConnectorException {

		AuthenticationStrategy auth = new BasicAuthenticationStrategy(username,
				password);
		HttpConnector<?> con = new SimpleJavaHttpConnector(null);
		BlipConnector res = new BlipConnector(con,auth,baseurl,"test yajba",true);
		return res;
	}
}
